chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  if (request.action === 'downloadImage') {
    chrome.downloads.download({
      url: URL.createObjectURL(request.imageData),
      filename: request.fileName,
      saveAs: false
    });
  }
});